package br.com.unisinos.unitunes.framework.conexao;
  
import br.com.unisinos.unitunes.framework.log.Log;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class AcessoDatabaseOracle {  
      
    private Connection conexao = null;
    public Statement statement;
    public ResultSet resultset;
    
    private String driver = "oracle.jdbc.driver.OracleDriver";
    private String url = "jdbc:oracle:thin:@localhost:1521:XE";  
    private String usr = "UNITUNES";  
    private String pwd = "UNITUNES";
    
    Log log = new Log();
    
    public AcessoDatabaseOracle(){}  
      
    public boolean conectarDatabase(){  
        try{
            log.informaLog("Conectando o Banco de Dados: " + url);
            Class.forName(driver);  
            conexao = DriverManager.getConnection(url,usr,pwd);  
            return true;  
        }
        catch(Exception erro)
        {
            return false;
        }
    }
    
    public boolean desconectarDatabaseOracle(){  
        try{
            conexao.close();
            log.informaLog("Finalizando conexão com Banco de Dados: " + url);
            return true;  
        }
        catch(Exception erro)
        {
            return false;
        }
    }
    
  /*  public boolean executeSQL(String sql){  
        try{
            log.informaLog("Executando o método executeSQL()");
            statement = conexao.createStatement();
            resultset = statement.executeQuery(sql);
            
             // Percorre o ResultSet
            while (resultset.next())
          
            // Libera recursos
            resultset.close();
            statement.close();
            deconectarDatabase();
            return true;
        }
        catch(Exception erro)
        {
            System.out.println(erro.getMessage());
            return false;
        }
    }   */ 
}